home *** CD-ROM | disk | FTP | other *** search
/ Zoom 2 / Zoom - Release 2 (1996)(Active Software)[!].iso / programming / assembly / ex4_number3 / anim_test.s < prev    next >
Encoding:
Text File  |  1992-09-02  |  3.2 KB  |  108 lines

  1. *******************************************************************************
  2. * This mainloop below 'cycles' thru the animation.. It could be re-written to 
  3. * 'ping-pong' or play the animation once over, etc.
  4.  
  5. swidth        = 320                ;screen width
  6. sheight        = 256                ;screen height
  7. sdepth        = 4                ;screen depth
  8.  
  9.         section    test,code_c
  10.  
  11. ProgStart:    movem.l    d0-d7/a0-a6,-(sp) 
  12.         bsr    killsys
  13.  
  14. *-------------- Setup IFF Anim "Play structure.."
  15.  
  16.         lea    buf1,a0            ;ptr to anim screen buffer 1
  17.         lea    buf2,a1            ;ptr to anim screen buffer 2
  18.         lea    cop_dump+2(pc),a2    ;ptr to cols in copperlist
  19.         lea    animfile(pc),a3        ;ptr to animation to play
  20.         lea    Anim_Struct(pc),a6    ;ptr to animation struct mem
  21.         move.l    #endfile-animfile,d0    ;bytesize of animation file
  22.         bsr    _LVOAnimInit
  23.  
  24. *-------------- main loop
  25.  
  26. AnimLoop    cmp.b    #200,$dff006
  27.         bne.s    AnimLoop
  28.  
  29. *-------------- Anim double buffer (swap screens)
  30.  
  31.         lea    bplanes(pc),a0        ;ptr to bpls in copperlist
  32.         moveq    #40,d2            ;offset next bpl (interleaved)
  33.         lea    Anim_Struct(pc),a6    ;ptr to animation structure
  34.         bsr.w    _LVOAnimBuffer
  35.  
  36. *-------------- Unpack current animation frame..
  37.  
  38.         lea    Anim_Struct(pc),a6    ;ptr to animation structure
  39.         moveq    #40,d2            ;unpack screen width
  40.         bsr.w    _LVOAnimUnpackFrame
  41.  
  42. *-------------- check if we`ve animated all frames..
  43.  
  44.         move.w    frame_total(pc),d0
  45.         cmp.w    frame_current(pc),d0    ;last frame done?
  46.         ble.s    reset_frame
  47.  
  48. *-------------- if not, get to next frame..
  49.  
  50.         addq.w    #1,frame_current    ;to next frame no.
  51.  
  52.         moveq    #0,d0
  53.         move.b    frame_depth(pc),d0
  54.         add.w    d0,d0
  55.         add.w    d0,d0            ;inc to next frame gfx..
  56.         add.l    d0,frame_ptr        ;save frame ptr
  57.         bra.s    inc_done
  58.  
  59. *-------------- otherwise reset to 1st frame
  60.  
  61. reset_frame:    lea    frame_list(pc),a1
  62.         move.l    a1,frame_ptr        ;reset frame pointer
  63.         clr.w    frame_current        ;reset frame number to 0
  64.  
  65. inc_done:    btst    #6,$bfe001
  66.         bne.b    AnimLoop
  67.  
  68.         bsr.w    returnsys      
  69.         movem.l    (sp)+,d0-d7/a0-a6 
  70.         rts
  71.  
  72. *-------------- Animation structure -: Required for every seperate animation
  73. *        and configured by calling _LVOAnimInit with correct parameters.
  74.  
  75. Anim_Struct:    ds.l    1        ;IFF-Anim data ptr
  76. Anim_Length:    ds.l    1        ;IFF-Anim data size
  77. Anim_Copper:    ds.l    1        ;Palette copperlist dump adr
  78. Anim_Screen1:    ds.l    1        ;Screen buffer 1
  79. Anim_Screen2:    ds.l    1        ;Screen buffer 2
  80. Reserved:    ds.l    2        ;not used (reserved for future use)
  81. Frame_Width:    ds    1        ;Anim frame width
  82. Frame_Depth:    ds    1        ;Anim frame depth
  83. Frame_Total:    ds    1        ;Anim total frames
  84. Frame_Current:    ds    1        ;Anim current frame no.
  85. Frame_Ptr:    ds.l    1        ;Anim current frame gfx ptr
  86. Frame_List    ds.l    75*4        ;storage for frame list pointers
  87.         even            ;a ptr`s used for each plane of frames
  88.                     ;thus upto 75 frames worth is allocated    
  89.  
  90. copperlist    dc    bplcon0,$0200,ddfstrt,$38,ddfstop,$d0
  91.         dc    diwstrt,$1681,diwstop,$36c1,$1fc,$0,$106,0
  92.         dc    bplmod1,(swidth/8)*(sdepth-1)
  93.         dc    bplmod2,(swidth/8)*(sdepth-1)
  94. bplanes:    dc    $0e0,0,$0e2,0,$0e4,0,$0e6,0,$0e8,0,$0ea,0,$0ec,0,$0ee,0
  95. cop_dump:    dc    $180,0,$182,0,$184,0,$186,0,$188,0,$18a,0,$18c,0,$18e,0
  96.         dc    $190,0,$192,0,$194,0,$196,0,$198,0,$19a,0,$19c,0,$19e,0
  97.  
  98.         dc    $2809,-2,bplcon0,$4200    ;4 bitplanes..
  99.         dc    $ff09,-2,bplcon0,$0200
  100.         dc    -2
  101.  
  102.         include    'work:source/anim_code.i'
  103. animfile    incbin    'work:source/shots.anim'
  104. endfile:
  105.         section    bssmem,bss_c
  106. buf1:        ds.b    (swidth/8)*(sheight)*(sdepth)
  107. buf2:        ds.b    (swidth/8)*(sheight)*(sdepth)
  108.